package com.sharon.sharon_note.base.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {
    private Integer state;
    private String msg;
    private Object data;

    public JsonResult(StatusCode statusCode) {
        this.state = statusCode.getState();
        this.msg = statusCode.getMsg();
    }

    public JsonResult(StatusCode statusCode, Object data) {
        this.state = statusCode.getState();
        this.msg = statusCode.getMsg();
        this.data = data;
    }

    public static JsonResult success(Object data) {
        return new JsonResult(StatusCode.SUCCESS, data);
    }

    public static JsonResult success() {
        return success(null);
    }
}
